package List;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        list.add("one");
        System.out.println("list集合"+list);
        String s=list.get(2);//获取下标为3的数
        System.out.println(s);
        for (int i=0;i<list.size();i++){
            System.out.println(list.get(i));

        }
        for (String i:list){
            System.out.println(i);
        }
        Iterator<String> it=list.listIterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("-----------------------");
        String oid=list.set(2,"six");
        System.out.println(oid);
        System.out.println("被改变一个数的集合"+list);
        String remove=list.remove(0);
        System.out.println(remove);
        System.out.println("被删除一个数字的集合"+list);
        list.add(4,"seven");
        System.out.println("插入一个数字的集合"+list);




    }
}
